﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Schema;

namespace _03函数
{
    class Program
    {
        //函数定义-值传递-地址传递
        static void SetX( ref int x)
        {
            x = 1;
        }

        

       

        //在数组中查找数字是否存在
        static bool FindNumInArray(int x,int[] array)
        {
            foreach (var num in array)
            {
                if (num == x)
                    return true;
            }
            return false;
        }

        /// <summary>
        /// 抠除数组中的重复元素
        /// </summary>
        /// <param name="x">原数组</param>
        /// <returns>新数组</returns>
        static int[] RemoveRepeatNum(int[] x)
        {
            List<int> numList = new List<int>();
            for (int i = 0; i < x.Length; i++)
            {
                if (!FindNumInArray(x[i], numList.ToArray()))
                {
                    numList.Add(x[i]);
                }
            }
            return numList.ToArray();
        }

        

        static int Pow(int x,int n)
        {
            int sum = 1;
            for (int i = 0; i < n; i++)
            {
                sum *= x;
            }
            return sum;
        }

        static void MaxAndMin(int x, int y, out int max, out int min)
        {
            max = x > y ? x : y;
            min = x < y ? x : y;
        }
        static void Person(string name,string sex,int age =22,string country ="中国")
        {

        }
        static int Add(int a, int b=0, int c =0, int d =0, int e =0, int f =0, int g = 0)
        {
            return a + b + c + d + e + f + g;
        }
        static void Main(string[] args)
        {
            #region //抠除数组重复元素
            
            //抠除重复元素,形成新数组
            int[] xArray = {1,4,2,5,3,7,4,8};
            //Array.Sort(xArray);//排序
            //Array.Reverse(xArray);//逆转
            //从前往后查找某个数字是否在数组中存在,存在即返回下标，否则返回-1
            int index = Array.IndexOf(xArray,4);
            Array.Clear(xArray,0,2);

            foreach (var num in xArray)
            {
                Console.WriteLine(num);
            }
           

            #endregion
           
        }

    }
}
